<{Tinclude "commom/admin_header"}>
<link href="<?php echo CSS_PATH;?>to-do.css" rel="stylesheet" />
<style>
    #menulist ul{
        margin-top: 5px;
    }
</style>
 <section id="container" >
      
      <!--顶部-->
      <{Tinclude"commom/admin_inner_header"}>
      <!--顶部-->
      
       <{Tinclude"commom/admin_left_menu"}>
       
       <section id="main-content">
          <section class="wrapper tasks-widget">
          	<h3><i class="<{if $___menuinfo["iconclass"]}><{$___menuinfo["iconclass"]}><{else}>fa fa-list-ul<{/if}>"></i><{$___menuinfo["base_name"]}></h3>
                <div class="row mt">
                    <div class="col-md-12">
                       <div class="form-panel">
                           
                           <form class="form" role="form" action="<{echo Common::RewriteUrl($jp_arg["c"],$jp_arg["a"]);}>"  method="post">  
                               <div class="form-group input-group col-md-4">
   
                <span class="input-group-addon" id="basic-addon1">角色名</span>
                <input type="text" name="rolename" class="form-control" placeholder="请填写角色名...." aria-describedby="basic-addon1">

           </div>
                          

                               
                               
                               
                               <div class="form-group input-group col-md-12 col-xs-12 minheight">
          <textarea class="form-control" name="desc" placeholder="简单描述" rows="3"></textarea>
          </div>   
                            <div class="form-group input-group col-md-2">
   
                <span class="input-group-addon" id="basic-addon1">排序:</span>
                <input type="text" name="sort"  class="form-control" placeholder="1" aria-describedby="basic-addon1">
           </div>
                               
                                <div class="form-group input-group col-sm-4">
                                  <div class="switch switch-animate"
                                       data-on-label="启用"
                                       data-off-label="禁用">
                                      <input name="disabled" type="checkbox" checked />
                                  </div>
      </div>             
                     
                               <div class="form-group input-group col-md-12">
                                   <ul class="task-list ui-sortable" id="menulist">

                                    </ul>
                               </div>
                 
            <input class="btn btn-primary btn-block" type="submit" name="submit" value="提交">
                   
                               
                           </form>
                           
                           
                           
                       </div>
                    </div>
                        
                </div>
          </section>
       </section>
 </section>
<script>
    var json=<{$menujson}>;
    if(json){
       buildtree(json); 
    }
    function buildtree(_json){
         
        if(_json.length>0){
            var _new_json=new Array();
            for(var i=0;i<_json.length;i++){
                if(_json[i].parent_id==0){
                    $("#menulist").append("<li class=\"list-primary\" id=\"list"+_json[i].id+"\"><input type=\"checkbox\" value=\""+_json[i].id+"\" name=\"menuid[]\">"+_json[i].base_name+"</li>");
                   
                }else{
                    var parent=$("#list"+_json[i].parent_id);
                   
                    if(parent.get(0)){
                        var ismenu=$("ul.p"+_json[i].parent_id);
                       
                        if(!ismenu.get(0)){
                            ismenu=$("<ul class=\"task-list ui-sortable p"+_json[i].parent_id+"\"></ul>");
                            parent.append(ismenu);
                            
                        }
                        var content="<li class=\"list-primary\" id=\"list"+_json[i].id+"\"><input type=\"checkbox\" value=\""+_json[i].id+"\" name=\"menuid[]\">"+_json[i].base_name+"</li>";
                        ismenu.append(content);
                    }else{
                        _new_json.push(_json[i]);
                    }
                    
                }
                 
               
            }

            buildtree(_new_json);
        
        }
    }
    
    $(document).ready(function(){
        $("input[name='menuid[]']").click(function(){
            var flg=$(this).get(0).checked;
            var next=$(this).next("ul");
            var parents=$(this).parents(".task-list").prev("input[name='menuid[]']");
            parents.each(function(){
                if(flg){
                 $(this).get(0).checked=true;
                }
            });
            if(flg){
                next.find("input").each(function(){
                    $(this).get(0).checked=true;
                });
            }else{
                next.find("input").each(function(){
                    $(this).get(0).checked=false;
                });
            }
        });
    });
</script>
<{Tinclude"commom/admin_footer"}>